﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JQData.Core.DbModel
{
    public class HotMoneyTrade : EntityNotTenant
    {
        public int HotMoneyId { get; set; }

        public int StockId { get; set; }

        public DateOnly Date { get; set; }

        [MaxLength(20)]
        public string StockCode { get; set; }

        [MaxLength(50)]
        public string StockName { get; set; }

        public decimal BuyAmount { get; set; }

        public decimal SellAmount { get; set; }

        /// <summary>
        /// 净买入
        /// </summary>
        public decimal NetAmount { get; set; }

        /// <summary>
        /// 游资名称
        /// </summary>
        [MaxLength(50)]
        public string HmName { get; set; }

        /// <summary>
        /// 游资名称
        /// </summary>
        [MaxLength(4000)]
        public string HmOrgs { get; set; }

        /// <summary>
        /// 游资名称
        /// </summary>
        [MaxLength(500)]
        public string Tag { get; set; }

        /// <summary>
        /// 已经统计过
        /// </summary>
        //public bool IsTallied { get; set; }


        public bool IsBuy => BuyAmount != 0;


        public void Configure(EntityTypeBuilder<HotMoneyTrade> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.HasIndex(p => new
            {
                p.Date,
                p.StockId,
                p.HotMoneyId
            }).IsUnique();
        }
    }
}
